package cc.vv.btpartyjob.partymanager.delegate

import android.view.View
import android.widget.TextView
import cc.vv.baselibrary.view.BaseTopBarView
import cc.vv.baselibrary.view.ExpandTextview.ExpandTextView
import cc.vv.btpartyjob.jnimodule.server.OperationServer
import cc.vv.btpartyjob.partymanager.R
import cc.vv.btpartyjob.partymanager.moudel.bean.ProjectDetailJieDuanObj
import cc.vv.btpartyjob.partymanager.view.ProjectDetailProgessView
import cc.vv.mvp.delegate.BaseAppDelegate
import java.util.*

/**
 * 项目详情托管类
 * Created by Chen.qi on 2018/10/24.
 */
class ProjectDetailActivityDelegate : BaseAppDelegate() {

    override fun initWidget() {

    }

    override fun initLayoutRes(): Int {
        return R.layout.activity_project_detail
    }

    /**设置标题title*/
    fun setTopBarTitle(topBarTitle: String) {
        val titleBar = getView<BaseTopBarView>(R.id.btv_apd_topBar)
        titleBar?.setTitle(topBarTitle)
    }

    /**设置标题右边按钮点击事件*/
    fun setTitleBackBtnOnClick(event: BaseTopBarView.EventInterface) {
        val titleBar = getView<BaseTopBarView>(R.id.btv_apd_topBar)
        titleBar?.setEventInterface(event)
    }

    /**
     * 设置项目名称
     */
    fun setProjectName(proName: String?) {
        val projectView = getView<TextView>(R.id.tv_apd_projectName)
        projectView?.text = proName
    }

    /**
     * 设置项目介绍
     */
    fun setProjectIntroduceContent(proStr: String?) {
        val projectView = getView<ExpandTextView>(R.id.etv_apd_projectIntroduction)
        projectView?.text = proStr
    }

    /**
     * 设置项目介绍
     */
    fun setProjectType(proStr: String?) {
        val projectView = getView<TextView>(R.id.tv_apd_projectType)
        projectView?.text = proStr
    }


    /**
     * 项目周期类型
     */
//    fun setProjectWeekType(proStr: String?) {
//        val projectView = getView<TextView>(R.id.tv_apd_periodType)
//        projectView?.text = proStr
//    }

    /**
     * 项目负责人姓名
     */
    fun setProjectPrincipalName(proStr: String?) {
        val projectView = getView<TextView>(R.id.tv_apd_principalName)
        projectView?.text = proStr
    }


    /**
     * 项目负责人电话
     */
    fun setProjectPrincipalPhone(proStr: String?) {
        val projectView = getView<TextView>(R.id.tv_apd_principalTelPhone)
        projectView?.text = proStr
    }

    /**
     * 申报时间
     */
    fun setProjectShenBaoTime(proStr: String?) {
        val projectView = getView<TextView>(R.id.tv_apd_applyDataTime)
        projectView?.text = OperationServer.formatStr(proStr)
    }

    /**
     * 可见范围
     */
    fun setKeJian(proStr: String?) {
        val projectView = getView<TextView>(R.id.tv_apd_visualRange)
        var keJianStr = ""
        when (proStr) {
            "0" -> keJianStr = "本网格可见"
            "1" -> keJianStr = "本单位可见"
            "2" -> keJianStr = "本社区可见"
            "3" -> keJianStr = "本街道可见"
            "4" -> keJianStr = "宝塔区可见"
        }
        projectView?.text = keJianStr
    }

    /**
     * 项目进程
     */
    fun setProjectProessJieDuan(optionList: ArrayList<ProjectDetailJieDuanObj>?, state: Int?) {
        val projectJieduan = getView<ProjectDetailProgessView>(R.id.apv_adp_projectState)
        projectJieduan?.addAllSelectedFileView(optionList, state)
    }

    /**
     * 取消项目申请是否可见
     */
    fun setCancelApply(isShow: Boolean) {
        val projectView = getView<TextView>(R.id.tv_adp_cancelApply)
        if (isShow) {
            projectView?.visibility = View.VISIBLE
        } else {
            projectView?.visibility = View.GONE
        }
    }

    /**
     * 延期项目申请是否可见
     */
    fun setYanQiState(isShow: Boolean) {
        val projectView = getView<TextView>(R.id.tv_adp_yanQi)
        if (isShow) {
            projectView?.visibility = View.VISIBLE
        } else {
            projectView?.visibility = View.GONE
        }
    }

    /**
     * 整体项目内容
     */
    fun setZTContent(content: String) {
        val zhiTiView = getView<TextView>(R.id.tv_lpzT_projectContent)
        zhiTiView?.text = content
    }


    /**
     * 整体预警时间
     */
    fun setZTWarningTime(time: String?) {
        val zhiTiView = getView<TextView>(R.id.tv_lpzT_projectWarningTime)
        zhiTiView?.text = OperationServer.formatStr(time)
    }


    /**
     * 整体完成时间
     */
    fun setZTCompleteTime(completeTime: String?) {
        val zhiTiView = getView<TextView>(R.id.tv_lpzT_planCompleteDate)
        zhiTiView?.text = OperationServer.formatStr(completeTime)
    }

    /**
     * 整体项目状态
     */
    fun setZTStatus(state: Int?) {
        val zhiTiView = getView<TextView>(R.id.tv_lpzT_projectStatus)
        when (state) {
            0 -> {
                zhiTiView?.text = "未开始"
            }
            1 -> {
                zhiTiView?.text = "进行中"
            }
            2 -> {
                zhiTiView?.text = "已完成"
            }
        }
    }
}